package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseMarketControllerApi;
import com.xuecheng.api.content.model.dto.CourseMarketDTO;
import com.xuecheng.content.convert.CourseMarketConvert;
import com.xuecheng.content.entity.CourseMarket;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.content.service.CourseMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 课程营销信息 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CourseMarketController implements CourseMarketControllerApi {

    @Autowired
    private CourseMarketService  courseMarketService;

    @Override
    @GetMapping("/courseMarket/all")
    public List<CourseMarketDTO> queryAll() {
        List<CourseMarket> courseMarket = courseMarketService.list();
        return CourseMarketConvert.INSTANCE.entitys2dtos(courseMarket);
    }
    @Override
    @GetMapping("/courseMarket/{id}")
    public CourseMarketDTO queryById(@PathVariable("id") Long id) {
        CourseMarket courseMarket = courseMarketService.getById(id);
        return CourseMarketConvert.INSTANCE.entity2dto(courseMarket);
    }
}
